import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('@/pages/Home.vue'),
    children: [
      // {
      //   path: "/",
      //   name: "index",
      //   component: () => import("../components/index"),
      // }
    ]
  },
  {
    path: '/test',
    component: () => import('@/pages/test.vue'),
    children: []
  }
]

const router = new VueRouter({
  mode: 'history',
  routes: routes,
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})

// router.beforeEach((to, from, next) => {
//   // if (to.matched.some((record) => record.meta.requiresAuth)) {
//   //   if (!Boolean(localStorage.getItem('adminToken'))) {
//   //     next({
//   //       path: '/verify',
//   //       query: { redirect: to.fullPath }
//   //     })
//   //   } else {
//   //     next()
//   //   }
//   // } else {
//   //   next()
//   // }
//   next()
// })

export default router
